package com.efruit.struts.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.efruit.externalInterfaces.IProductInfoMag;
import com.efruit.productInfoMag.IProductInfo;

public class ListProductInfoAction  extends Action{
	
	IProductInfoMag productInfoMag = null;
	
	public IProductInfoMag getProductInfoMag() {
		return productInfoMag;
	}

	public void setProductInfoMag(IProductInfoMag productInfoMag) {
		this.productInfoMag = productInfoMag;
	}
	
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		try {
			System.out.println("**＊*＊*＊*＊*＊*＊* before ");
			List<IProductInfo> list = productInfoMag.getAllProductInfo();
			System.out.println("**＊*＊*＊*＊*＊*＊* list.size() = "+list.size());
			request.setAttribute("productInfoList", list);
			return mapping.findForward("listProductInfo");
		} catch (Exception e) {
			return mapping.findForward("error");
		}
	}
}
